{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['xgb17.csv', 'xgb35.csv', 'xgb11.csv', 'xgb12.csv', 'xgb8.csv', 'xgb33.csv', 'xgb3.csv', 'xgb6.csv', 'xgb18.csv', 'xgb14.csv', 'xgb25.csv', 'xgb4.csv', 'xgb29.csv', 'xgb9.csv', 'xgb27.csv', 'xgb13.csv', 'xgb31.csv', 'xgb20.csv', 'xgb0.csv', 'xgb24.csv', 'xgb19.csv', 'xgb26.csv', 'xgb2.csv', 'xgb23.csv', 'xgb5.csv', 'xgb32.csv', 'xgb21.csv', 'xgb1.csv', 'xgb34.csv', 'xgb15.csv', 'xgb7.csv', 'xgb10.csv', 'xgb22.csv', 'xgb30.csv', 'xgb28.csv', 'xgb16.csv']\n"
     ]
    }
   ],
   "source": [
    "files = os.listdir('./preds')\n",
    "print(files)\n",
    "pred = pd.read_csv('./preds/'+files[0])\n",
    "id = pred.id\n",
    "score = pred.score\n",
    "for f in files[1:]:\n",
    "    pred = pd.read_csv('./preds/'+f)\n",
    "    score += pred.score\n",
    "\n",
    "score /= len(files)\n",
    "\n",
    "pred = pd.DataFrame(id,columns=['id'])\n",
    "pred['prob'] = score\n",
    "pred.to_csv('svm_preds.csv',index=None,encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
